<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="./lib/vue-2.4.0.js"></script>

</head>

<body>
    <div id="app">
        <input type="text" v-model="firstname"> +
        <input type="text" v-model="secondname"> +
        <input type="text" v-model="thirdname"> =
        <input type="text" v-model="finalname">

    </div>
    <script>
        var vm = new Vue({
            el: "#app",
            data: {
                firstname: "",
                secondname: "",
                thirdname: "",
                // finalname: ""
            },
            computed: {
                'finalname': function () {
                    // 计算属性，需要return，不适合做大量操作。结果会被缓存，除非结果发生变化。
                    return this.finalname = this.firstname + "-" + this.secondname + this.thirdname
                }
            }
        })
    </script>
</body>

</html>